<template>
  <div class="transTrend">
    <div class="title">
      <stitle :bg="bg" text="销售成交趋势" :type="0" />
    </div>
    <div class="tabs">
      <div class="tabs-item" v-for="(item, index) in tab" :key="index">
        <span class="name">{{ item.name }}</span>
        <span class="value">
          <te-flop
            :number="item.value"
            :animationTime="1"
            :intervalTime="10000"
            :flop-class="`flop${index}`"
          ></te-flop>
        </span>
        <span class="font">{{ item.font }}</span>
      </div>
    </div>
    <div id="echartTransTrend"></div>
  </div>
</template>

<script>
import stitle from "@/components/common/stitle";
import store from "@/utils/store";
export default {
  name: "transTrend",
  components: {
    stitle,
  },
  data() {
    return {
      bg: require("@/assets/images/DispatchCommand/stitle.png"),
      state: store.state,
      tab: [
        {
          name: "累计成交金额（万元）",
          value: 139563,
          font: "",
        },
        {
          name: "累计成交订单（件）",
          value: 6324,
          font: "",
        },
        {
          name: "累计退货订单（件）",
          value: 312,
          font: "",
        },
      ],
    };
  },
  mounted() {
    this.setEchart();
  },
  methods: {
    setEchart() {
      const _echarts = this.$echarts.init(
        document.getElementById("echartTransTrend")
      );
      const option = {
        grid: {
          bottom: "15%",
          right: "10%",
          top: "15%",
        },
        tooltip: {
          trigger: "axis",
          textStyle: {
            fontSize: 14,
            heigth: 50,
            width: 50,
          },
        },
        xAxis: {
          type: "category",
          data: [
            "1月",
            "2月",
            "3月",
            "4月",
            "5月",
            "6月",
            "7月",
            "8月",
            "9月",
            "10月",
            "11月",
            "12月",
          ],
          axisLine: {
            lineStyle: {
              color: "#fff",
            },
          },
          axisLabel: {
            textStyle: {
              color: "#fff",
              fontSize: 14,
            },
          },
        },
        yAxis: {
          type: "value",
          name: "( 万元 )",
          axisLabel: {
            formatter: "{value}",
            textStyle: {
              color: "#fff",
              fontSize: 14,
            },
          },
          axisLine: {
            lineStyle: {
              color: "#fff",
            },
          },
          splitLine: {
            show: true,
            lineStyle: {
              color: ["#305383"],
              width: 1,
              type: "solid",
            },
          },
        },
        series: [
          {
            data: [38, 41, 25, 33, 31, 59, 69, 50, 56, 27, 54],
            type: "line",
            itemStyle: {
              color: "#DFA71C",
            },
            lineStyle: {
              color: "#DFA71C",
            },
            areaStyle: {
              color: {
                type: "linear",
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: "rgba(223, 167, 28, 1)", // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: "rgba(223, 167, 28, 0)", // 100% 处的颜色
                  },
                ],
                global: false, // 缺省为 false
              },
            },
            smooth: true,
          },
        ],
      };
      _echarts.setOption(option);
    },
  },
};
</script>

<style lang="scss" scoped>
.transTrend {
  position: absolute;
  width: 1000px;
  height: 650px;
  left: 450px;
  top: 100px;
  z-index: 999;
  background-image: url("~@/assets/images/salesData/bg.png");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  .title {
    width: 400px;
  }
  .tabs {
    width: 80%;
    margin: 30px auto;
    height: 80px;
    display: flex;
    justify-content: space-around;
    color: #fff;
    .tabs-item {
      width: 220px;
      height: 80px;
      background-repeat: no-repeat;
      background-size: 100% 100%;

      padding-top: 10px;
      box-sizing: border-box;
      .name {
        display: block;
        text-indent: 65px;
      }
      .value {
        display: inline-block;
        color: #229aff;
        font-size: 14px;
        font-family: ZZGFLQ;
        font-style: oblique;
        letter-spacing: 2px;
        line-height: 30px;
        margin-left: 65px;
      }
      .font {
        color: #bcdafb;
      }
    }
    .tabs-item:nth-child(1) {
      background-image: url("~@/assets/images/salesData/tab1.png");
    }
    .tabs-item:nth-child(2) {
      background-image: url("~@/assets/images/salesData/tab2.png");
    }
    .tabs-item:nth-child(3) {
      background-image: url("~@/assets/images/salesData/tab3.png");
    }
  }
  #echartTransTrend {
    width: 100%;
    height: 400px;
  }
  .te-flop /deep/ li {
    width: 14px;
  }
  .te-flop /deep/ .te-dataBoc--item span {
    font-size: 14px;
  }
}
</style>
